angular.module('elife.controllers')
  .controller('LoginCtrl', function($scope,$state,$rootScope,popupService) {
    var login = this;

    login.isPassword = true;//是否是密码登录

    login.enter = enter;
    login.goHome = goHome;
    login.switchType = switchType;
    login.register = register;
    login.modifyPassword = modifyPassword;

    function enter() {
      if((login.user == 'aaa' && login.password == '123') || ($rootScope.account && login.user == $rootScope.account.user && login.password == $rootScope.account.password)){
        $state.go('tab.home');
      } else {
        // alert("用户名或密码不正确");
        popupService.alert({
          title:"提示",
          template:"<div class='popup-padding-35'><span class='popup-color-gray'>用户名或密码不正确</span></div>",
          okText:"确认"
        }).popup.then(function(res){

        });
      }
    }

    function switchType(type){
      login.isPassword = type;
      if(!login.isPassword){
        gestureLogin();
      }
    }

    function goHome () {
        $state.go('tab.home');
    }



    function register(){
      //$state.go('register');
    }

    function modifyPassword(){
      //$state.go('password')
    }
  });
